package defn

//FlowDef the Flow definition.
//
//This is the metadata of the execution process, not the runnable part. The execution engine will
//transpile this structure into the runnable part to do the eventual execution.
type FlowDef struct {
	Label       string `json:"label"`
	Description string `json:"description"`
	Name        string `json:"name"`
	Version     string `json:"version"`

	StartElement string `json:"startElement"`

	Variables   []*Variable   `json:"variables"`
	Assignments []*Assignment `json:"assignments"`
	Decisions   []*Decision   `json:"decisions"`
}

//Node the abstract node definition.
type Node struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

//Variable the variable definition.
type Variable struct {
	Node
	DataType     string `json:"dataType"`
	DefaultValue string `json:"defaultValue"`
}

//ConnectedNode the node with single connector.
type ConnectedNode struct {
	Node
	Connector string `json:"connector"`
}

//AssignmentItem the assignment item.
type AssignmentItem struct {
	AssignTo string `json:"assignTo"`
	Operator string `json:"operator"`
	Value    string `json:"value"`
}

//Assignment the assignment node definition.
type Assignment struct {
	ConnectedNode
	AssignmentItems []*AssignmentItem `json:"assignmentItems"`
}

//DecisionRule the rule of a decision.
type DecisionRule struct {
	ConnectedNode
	Criteria string `json:"criteria"`
}

//Decision the decision node definition.
type Decision struct {
	Node
	DecisionRules         []*DecisionRule `json:"decisionRules"`
	DefaultConnector      string          `json:"defaultConnector"`
	DefaultConnectorLabel string          `json:"defaultConnectorLabel"`
}
